import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
from sklearn.preprocessing import LabelEncoder


train=pd.read_csv("playground-series-s4e2/train.csv")
test=pd.read_csv("playground-series-s4e2/test.csv")

X = train.drop(['id', 'NObeyesdad'], axis=1)
y = train['NObeyesdad']


lab = LabelEncoder()
y_int = lab.fit_transform(y)

object_columns = [i  for i in X.columns if X[i].dtype.name == 'object']

X[object_columns] = X[object_columns].astype('category')






X_train, X_test, y_train, y_test = train_test_split(X, y_int, test_size=0.2, random_state=42)

from xgboost import XGBClassifier
xgb = XGBClassifier(random_state=42
                    , n_estimators=100
                    , max_depth=20
                    , min_samples_split=2
                    , min_samples_leaf=1
                    , enable_categorical=True
                    , tree_method='hist'# gpu_hist    auto    approx
                    )
xgb.fit(X_train, y_train)
y_pred = xgb.predict(X_test)

print('Accuracy:', accuracy_score(y_test, y_pred))
print('Classification Report:', classification_report(y_test, y_pred))
print('Confusion Matrix:', confusion_matrix(y_test, y_pred))